import { httpInstance } from "@/utils/httpInstance";

export type LoginFormData = {
    mobile: string,
    code: string,
};

// 登录API
export const loginAPI = (formData: LoginFormData) => {
    const controller = new AbortController();
    const request = httpInstance.request<{ token: string }>({ url: '/authorizations', method: 'POST', data: formData, signal: controller.signal });
    return { request, controller };
};

type UserInfo = {
    id: string,
    photo: string,
    name: string,
    mobile: string,
    gender: 1 | 2,
    birthday: string
};

// 获取用户信息API
export const getUserInfoAPI = () => {
    const controller = new AbortController();
    const request = httpInstance.request<UserInfo>({ url: '/user/profile', method: 'GET', signal: controller.signal });
    return { request, controller };
};